<?php
//var_dump($user_data_refree); die();
$this->load->view('user/head');
$this->load->view('user/header');
//var_dump($form_detail);die();
?>
<script type="text/javascript" src="<?php echo ASSET_URL; ?>js/jquery-1.10.2.js"></script>
<script>
$(document).ready(function(){
	$("#applicant_form_submit_personal").click(function(){
		
		<?php if(isset($form_list)) { 
				foreach($form_list as $row){
					if($row['master_application_form_mandatory']=='Yes'){ ?>
					 if($("<?php echo "#".$row['master_application_form_name'];?>").val() ==""){
						 
							$('<?php echo "#err-".$row['master_application_form_name']; ?>').html('<?php echo "Please enter ".strtolower($row['event_application_form_label']); ?>');
							$('<?php echo "#err-".$row['master_application_form_name']; ?>').show(500);
							$('<?php echo "#err-".$row['master_application_form_name']; ?>').delay(4000);
							$('<?php echo "#err-".$row['master_application_form_name']; ?>').animate({
							height: 'toggle' 
							}, 500, function() {
							// Animation complete.
							});
							return false;
					<?php $flag2=FALSE; ?>
					 } else {
						 <?php $flag2=TRUE; ?>
					 }
				<?php } } 
				if($flag2){ ?>
					$("#user_application_form").submit();
			<?php } }?>
		//$form_list[0]['event_application_form_id']
	});
});
</script>
<script>
$(document).ready(function(){
	$("#applicant_form_submit_edu").click(function(){
		<?php if(isset($form_list_edu)) { 
				foreach($form_list_edu as $row){ 
				if($row['master_application_form_mandatory']=='Yes'){ ?>
					 if($("<?php echo "#".$row['master_application_form_name'];?>").val() ==""){
						 
							$('<?php echo "#err-".$row['master_application_form_name']; ?>').html('<?php echo "Please enter ".strtolower($row['event_application_form_label']); ?>');
							$('<?php echo "#err-".$row['master_application_form_name']; ?>').show(500);
							$('<?php echo "#err-".$row['master_application_form_name']; ?>').delay(4000);
							$('<?php echo "#err-".$row['master_application_form_name']; ?>').animate({
							height: 'toggle' 
							}, 500, function() {
							// Animation complete.
							});
							return false;
					<?php $flag2=FALSE; ?>
					 } else {
						 <?php $flag2=TRUE; ?>
					 }
				<?php } } 
				if($flag2){ ?>
					$("#user_application_edu_form").submit();
			<?php } }?>
		//$form_list[0]['event_application_form_id']
	});
});
</script>

<script>
$(document).ready(function(){
$("#applicant_form_submit_doc").click(function(){
	<?php if(isset($form_list_doc)){
			foreach($form_list_doc as $row) { ?>
				var file = $('<?php echo "#".$row['master_application_form_name'];?>').val();
					if(file == ""){
						$('<?php echo "#err-".$row['master_application_form_name']; ?>').html('<?php echo "Please upload a file";?>');
						$('<?php echo "#err-".$row['master_application_form_name']; ?>').show(500);
						$('<?php echo "#err-".$row['master_application_form_name']; ?>').delay(4000);
						$('<?php echo "#err-".$row['master_application_form_name']; ?>').animate({
						height: 'toggle' 
						}, 500, function() {
						// Animation complete.
						});
						return false;
						<?php $flag3 = FALSE; ?>
					}else {
						var exts = ['doc','docx','rtf','odt','pdf'];
						// split file name at dot
						var get_ext = file.split('.');
						// reverse name to check extension
						get_ext = get_ext.reverse();
						// check file type is valid as given in 'exts' array
						if ( $.inArray ( get_ext[0].toLowerCase(), exts ) > -1 ){
					 	<?php $flag3 = TRUE; ?>
						}
						else {
							$('<?php echo "#err-".$row['master_application_form_name']; ?>').html('<?php echo "Please upload a valid document";?>');
							$('<?php echo "#err-".$row['master_application_form_name']; ?>').show(500);
							$('<?php echo "#err-".$row['master_application_form_name']; ?>').delay(4000);
							$('<?php echo "#err-".$row['master_application_form_name']; ?>').animate({
							height: 'toggle' 
							}, 500, function() {
							// Animation complete.
							});
							return false;
							<?php $flag3 = FALSE;?>
						}
					}
		<?php }}
			if(empty($flag3)){ ?>
			$("#user_application_doc_form").submit();
				<?php 
			}
		?>
	});
});
</script>
<script>
$(document).ready(function(){
	$("#applicant_form_submit_refree").click(function(){
	<?php if(isset($form_detail[0]['award_refree_count'])){ 
			for($i=1 ; $i<=$form_detail[0]['award_refree_count'];$i++){ ?>
				if($("<?php echo "#refree_name".$i;?>").val() ==""){
					$('<?php echo "#err-refree_name".$i; ?>').html('<?php echo "Refree name is required";?>');
					$('<?php echo "#err-refree_name".$i; ?>').show(500);
					$('<?php echo "#err-refree_name".$i; ?>').delay(4000);
					$('<?php echo "#err-refree_name".$i; ?>').animate({
					height: 'toggle' 
					}, 500, function() {
					// Animation complete.
					});
					return false;
					<?php $flag = TRUE; ?>
				}
				else if($("<?php echo "#refree_email".$i;?>").val() ==""){
					$('<?php echo "#err-refree_email".$i; ?>').html('<?php echo "Refree Email is required";?>');
					$('<?php echo "#err-refree_email".$i; ?>').show(500);
					$('<?php echo "#err-refree_email".$i; ?>').delay(4000);
					$('<?php echo "#err-refree_email".$i; ?>').animate({
					height: 'toggle' 
					}, 500, function() {
					// Animation complete.
					});
					return false;
					<?php $flag = TRUE; ?>
				}else {
					<?php $flag = FALSE; ?>
				}
	<?php }	}
	if(isset($flag)){ ?>
		$("#user_application_refree_form").submit();
	<?php } ?>
	
	});
});
</script>

<div class="space40"></div>
<img src="<?php echo ASSET_URL . 'img/slider/02.jpg'; ?>" alt="">
<div class="container">
    <div class="row">
    	<div class="col-md-3 col-xs-12">
          <?php $this->load->view('user/user_left_part'); ?>
        </div>
        <div class="col-md-9 col-xs-12">
        	<div class="error error_msg" id="err-top" style="font-size:14px;margin:10px 0 0 0;">
        		<?php if($this->session->userdata('success_submit_app') && $this->session->userdata('success_submit_app') != ''){
        			echo $this->session->userdata('success_submit_app');$this->session->unset_userdata('success_submit_app');
        		}else{ echo '&nbsp;';} ?>
        		<?php if($this->session->userdata('fill_personal') && $this->session->userdata('fill_personal') != ''){
        			echo $this->session->userdata('fill_personal');$this->session->unset_userdata('fill_personal');
        		}else{ echo '&nbsp;';} ?>
        	</div>
		<!--form_details starts-->
        	<div id="personal_div" style="<?php if(($this->session->userdata('user_form_next') && $this->session->userdata('user_form_next')=='personal') || ($this->session->userdata('user_form_next1') && $this->session->userdata('user_form_next1')=='personal')){ echo 'display:block';}else{ echo 'display:none';} ?>">
        		<?php $this->load->view('user/application_form_inner'); ?>
        	</div>
        	<div id="edu_div" style="<?php if($this->session->userdata('user_form_next') && $this->session->userdata('user_form_next')=='education'){ echo 'display:block';}else{ echo 'display:none';} ?>;">
        		<?php $this->load->view('user/application_form_inner1'); ?>
        	</div>
        	<div id="doc_div" style="<?php if($this->session->userdata('user_form_next') && $this->session->userdata('user_form_next')=='document'){ echo 'display:block';}else{ echo 'display:none';} ?>;">
        		<?php $this->load->view('user/application_form_inner2'); ?>
        	</div>
        	<?php if(isset($form_detail[0]['award_refree_count']) && $form_detail[0]['award_refree_count'] > 0){ ?>
        	<div id="refree_div" style="<?php if($this->session->userdata('user_form_next') && $this->session->userdata('user_form_next')=='refree'){ echo 'display:block';}else{ echo 'display:none';} ?>;">
        		<?php $this->load->view('user/application_form_inner3'); ?>
        	</div>
        	<?php }?>
        <!--form_details ends-->
		</div>
    </div>
    <div class="clearfix"></div>
    <div class="space90"></div>  
</div> 
<div class="space30"></div>
<?php $this->session->unset_userdata('user_form_next');$this->session->unset_userdata('user_form_next1'); ?>    
<?php $this -> load -> view('user/footer'); ?>